package sjsu.cmpe235;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

public class MediaPlayerActivity extends Activity {
	private String mediaURL;
	private VideoView mVideoView;

	/** Called when the activity is first created. */
	@Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mediaplayer);
        
        // get the parameter value
        mediaURL = getIntent().getStringExtra("mediaURL");
        
        mVideoView = (VideoView) findViewById(R.id.video_view);
        MediaController mediaController = new MediaController(this);
        mediaController.setAnchorView(mVideoView);
        
        Log.d("BARCODE", "Media URL = " + mediaURL);        
        if(mediaURL==""){
            Toast.makeText(this, "media file URL/path is null", Toast.LENGTH_LONG).show();
        }else{
        	// load the multimedia conent in a media player
            mVideoView.setVideoURI(Uri.parse(mediaURL));
            mVideoView.setMediaController(mediaController);
            mVideoView.start();
        }
    }
}
